package com.relytosoft.mizar.media.display.services.consumer;

import com.relytosoft.mizar.media.external.api.display.service.CruisePathService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 轨迹mq消费者类
 * @author hj
 * @version 1.0
 * @date 2022/4/13 17:20
 * @ClassName CruiseConsumer
 */
@Component
public class CruiseConsumer {

    protected Logger log = LoggerFactory.getLogger(this.getClass());

    @Resource
    private CruisePathService cruisePathService;

//    @KafkaListener(id = CRUISE_ID,topics = MediaMqConstants.DISPLAY_CRUISE_TOPIC, containerFactory = "singleContainerFactory")
//    public void processSingleMessage(ConsumerRecord<?, ?> record, Acknowledgment ack) {
//        try {
//            KafkaOpMsg kafkaOpMsg = JSON.parseObject(record.value().toString(), KafkaOpMsg.class);
//            CruiseDto dto = JSON.parseObject(kafkaOpMsg.getData(), CruiseDto.class);
//            switch (kafkaOpMsg.getOpType()) {
//                case INSERT:
//                    cruisePathService.addCruise(dto);
//                    break;
//                case UPDATE:
//                    cruisePathService.updateCruise(dto);
//                    break;
//                case DELETE:
//                    cruisePathService.deleteCruise(dto);
//                    break;
//                case CONTROL:
//                    cruisePathService.controlCruise(dto);
//                    break;
//                default:
//            }
//            log.info("线程:{} 消费->{}", Thread.currentThread(), kafkaOpMsg.getOpType());
//            ack.acknowledge();
//        } catch (Exception e) {
//            log.error(e.getMessage());
//        }
//    }



}
